﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.IO;

namespace DR5.SPExtend
{
    public static class HttpResponseExtension
    {
        public static void WriteStream(this HttpResponse response, Stream input)
        {
            byte[] buffer = new byte[16 * 1024];
            byte[] output;
            using (MemoryStream ms = new MemoryStream())
            {
                int read;
                while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
                {
                    ms.Write(buffer, 0, read);
                }
                output = ms.ToArray();
            }
            response.OutputStream.Write(output, 0, output.Length);
        }

        public static void WriteStream(this HttpResponse response, byte[] output)
        {
            response.OutputStream.Write(output, 0, output.Length);
        }
    
    }
}
